package cn.wolfcode.trip.api.controller;


import cn.wolfcode.trip.base.domain.OrderForm;
import cn.wolfcode.trip.base.service.IOrderFormService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 酒店订单资源控制器
 */
@RestController
@RequestMapping("orderForms")
public class OrderFormController {
    @Autowired
    private IOrderFormService orderFormService;

    /**
     *新增订单 
     * 1,资源           orderForms
     * 2，请求方式      put
     * 3,接收参数       OrderForm
     * 4，返回值        JsonResult
     */
    @PutMapping
    public JsonResult saveOrUpdate(OrderForm orderForm){
        orderFormService.saveOrUpdate(orderForm);
        return new JsonResult();
    }

    /**
     * 根据用户的id查询酒店订单
     */
    @GetMapping("{userId}")
    public List<OrderForm> getUserIdOrderForm(@PathVariable Long userId){
      return  orderFormService.getUserIdOrderForm(userId);
    }
}
